<#include "/common/layout.html"> 
<@body>
<div class="content">
	<form class="form-horizontal" method="post" action="${request.contextPath}/system/user/doEdit" id="userEditFrom" >
		<div class="box-body">
			<div class="form-group">
				<label class="col-sm-2 control-label">用户名</label>
				<input type="hidden" value="${sysUser.userId}" name="userId" id="userId">
				<div class="col-sm-10">
					<input type="text" id="userName" name="userName" value="${(sysUser.userName)!}" class="form-control" placeholder="请输入用户名" required>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">部门</label>
				<div class="col-sm-10">
				<select name="deptId" class="form-control select2" style="width: 100%;">
					<#list deptList as dept>
					<option value="${(dept.deptId)!}"  ${(sysUser.deptId?? && dept.deptId==sysUser.deptId)?string('selected="selected"','')} >${(dept.deptName)!}</option>
					</#list>
				</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">密码</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" id="password"  name="password" placeholder="密码为空则不修改密码">
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">描述</label>
				<div class="col-sm-10">
					<textarea class="form-control" id="userDesc" name="userDesc" rows="3" placeholder="请输入描述，最多300个字符 ..." required>${(sysUser.userDesc)!}</textarea>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">状态</label>
				<div class="col-sm-10">
					<label class="radio-box">
						<input name="userState" type="radio" class="minimal" ${(sysUser.userState == 1)?string('checked','')} value="1" required> 启用
					</label>
					<label class="radio-box">
						<input name="userState" type="radio" class="minimal" ${(sysUser.userState == -1)?string('checked','')}  value="-1"> 禁用
					</label>
				</div>
			</div>
			<div class="form-group">
				<label  class="col-sm-2 control-label">角色分配</label>
				<div class="col-sm-10">
					<#if sysUser.userId == 1>
						<label title="超级管理员" style="margin-top:7px;">
							超级管理员
						</label>
					<#else>
						<#list sysRoles as role>
						<label class="check-box" title="${(role.roleDesc)!}">
							<input type="checkbox" name="roleId[]" class="minimal" ${(myRolds?seq_contains(role.roleId))?string('checked','')}  value="${(role.roleId)!}">
							${(role.roleName)!}
						</label>
						&nbsp;
						</#list>
					</#if>
				</div>
			</div>
		</div>
	</form>
</div>
</@body>
<script type="text/javascript">
	var icon = "<i class='fa fa-times-circle'></i>";
	function submitHandler() {
		if ($("#userEditFrom").validate().form()) {
			var formData = $("#userEditFrom").serialize();
			$.ajax({
				url : $("#userEditFrom").attr('action'),
				type : 'POST',
				dataType: "json",
				data : formData,
				beforeSend : function() {
					$.modal.loading("正在处理中，请稍后...");
					$.modal.disable();
				},
				success : function(data) {
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						parent.layer.closeAll('iframe'); // 关闭当前frame
						window.parent.data_oTable.draw(false);
					} else {
						parent.layer.msg(data.msg, {
							icon : 1
						});
						$.modal.closeLoading();
						$.modal.enable();
					}
				}
			});
		}
	}
</script>
